package com.bedrock.project.inside.service.impl;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bedrock.common.utils.DateUtils;
import com.bedrock.project.inside.entity.WaitAffair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bedrock.project.inside.mapper.WaitAffairMapper;
import com.bedrock.project.inside.service.IWaitAffairService;

/**
 * 待办事项Service业务层处理
 * 
 * @author bedrock
 * @date 2020-04-08
 */
@Service
public class WaitAffairServiceImpl implements IWaitAffairService 
{
    @Autowired
    private WaitAffairMapper waitAffairMapper;

    /**
     * 查询待办事项
     * 
     * @param id 待办事项ID
     * @return 待办事项
     */
    @Override
    public WaitAffair selectWaitAffairById(Long id)
    {
        return waitAffairMapper.selectWaitAffairById(id);
    }

    /**
     * 查询待办事项列表
     * 
     * @param waitAffair 待办事项
     * @return 待办事项
     */
    @Override
    public List<WaitAffair> selectWaitAffairList(WaitAffair waitAffair)
    {
        return waitAffairMapper.selectWaitAffairList(waitAffair);
    }

    /**
     * 新增待办事项
     * 
     * @param waitAffair 待办事项
     * @return 结果
     */
    @Override
    public int insertWaitAffair(WaitAffair waitAffair)
    {
        waitAffair.setCreateTime(DateUtils.getNowDate());
        return waitAffairMapper.insertWaitAffair(waitAffair);
    }

    /**
     * 修改待办事项
     * 
     * @param waitAffair 待办事项
     * @return 结果
     */
    @Override
    public int updateWaitAffair(WaitAffair waitAffair)
    {
        waitAffair.setUpdateTime(DateUtils.getNowDate());
        return waitAffairMapper.updateWaitAffair(waitAffair);
    }

    /**
     * 批量删除待办事项
     * 
     * @param ids 需要删除的待办事项ID
     * @return 结果
     */
    @Override
    public int deleteWaitAffairByIds(Long[] ids)
    {
        return waitAffairMapper.deleteWaitAffairByIds(ids);
    }

    /**
     * 删除待办事项信息
     * 
     * @param id 待办事项ID
     * @return 结果
     */
    @Override
    public int deleteWaitAffairById(Long id)
    {
        return waitAffairMapper.deleteWaitAffairById(id);
    }

    /**
     * 按流程id 修改处理人
     * @param doUserId
     * @param flowId
     */
    @Override
    public void updateWaitFlowDouserId(Long doUserId,Long flowId){

        try{

            Map map = new HashMap();
            map.put("doUserId",doUserId);
            map.put("flowId",flowId);
            waitAffairMapper.updateWaitFlowDouserId(map);

        }catch (SQLException ex){
            ex.printStackTrace();
        }


    }

}
